<!--
 * @Author: g05047
 * @Date: 2021-11-24 10:29:34
 * @LastEditors: g05047
 * @LastEditTime: 2021-11-25 0:58:53
 * @Description: file content
-->
<template>
  <div class="classroom">
    <el-row type="flex" align="middle" >
       <el-button @click="onGoback"    style="margin-right: 20px" icon="el-icon-back" type="primary"
            >返回上一页</el-button
          >
      <el-date-picker
        v-model="timeList"
        type="daterange"
        range-separator="—"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        format="yyyy-MM-dd "
        value-format="yyyy-MM-dd"
        @change="onTimeChange"
        clearable
      >
      </el-date-picker>
      <el-button
        style="margin-left: 20px"
        icon="el-icon-search"
        type="primary"
        @click="search"
        >查询</el-button
      >
      <el-button
        style="margin-left: 20px"
        type="default"
        @click="handleExportMarketingList"
        >导出</el-button
      >
   
    </el-row>

    <el-table
      ref="table"
      class="table"
      border
      :data="tableData"
      style="width: 100%; margin-top: 20px"
    >
      <el-table-column
        fixed="left"
        align="center"
        prop="area"
        label="区域名称"
        width="120"
      >
      </el-table-column>
      <el-table-column align="center" label="餐饮服务经营者" :index="1">
        <el-table-column align="center" label="特大型餐饮">
          <el-table-column
            align="center"
            prop="content[5].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[5].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[5].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="大型餐饮">
          <el-table-column
            align="center"
            prop="content[2].unRegister"
            label="应注册"
            :index="2"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[2].registered"
            label="已注册"
            :index="2.1"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[2].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="中型餐饮">
          <el-table-column
            align="center"
            prop="content[0].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[0].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[0].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="小型餐饮">
          <el-table-column
            align="center"
            prop="content[3].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[3].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[3].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="微型餐饮">
          <el-table-column
            align="center"
            prop="content[4].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[4].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[4].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="集体用餐配送或中央厨房">
          <el-table-column
            align="center"
            prop="content[6].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[6].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[6].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="其他餐饮">
          <el-table-column
            align="center"
            prop="content[1].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[1].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[1].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
      </el-table-column>
      <el-table-column align="center" label="单位食堂">
        <el-table-column align="center" label="幼托机构食堂">
          <el-table-column
            align="center"
            prop="content[11].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[11].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[11].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="学校食堂">
          <el-table-column
            align="center"
            prop="content[9].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[9].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[9].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="养老机构食堂">
          <el-table-column
            align="center"
            prop="content[8].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[8].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[8].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="工地食堂">
          <el-table-column
            align="center"
            prop="content[10].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[10].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[10].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="机关企事业单位食堂">
          <el-table-column
            align="center"
            prop="content[12].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[12].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[12].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="其他食堂">
          <el-table-column
            align="center"
            prop="content[7].unRegister"
            label="应注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[7].registered"
            label="已注册"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="content[7].proportion"
            label="注册占比"
          >
          </el-table-column>
        </el-table-column>
      </el-table-column>
      <el-table-column
        fixed="right"
        align="center"
        prop="total"
        label="合计"
        width="240"
      >
        <el-table-column align="center" prop="total" label="应注册">
        </el-table-column>
        <el-table-column align="center" prop="totalRegister" label="已注册">
        </el-table-column>
        <el-table-column align="center" prop="proportion" label="注册占比">
        </el-table-column>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { exportTb } from "@/utils/XLSX";
export default {
  data() {
    return {
      timeList: [],
      tableData: [
        {
          area: "高新区",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 12,
              registered: 7,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 126,
              registered: 93,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 424,
              registered: 326,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 1542,
              registered: 1324,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 2117,
              registered: 1821,
            },

            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 58,
              registered: 39,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 92,
              registered: 79,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 11,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 373,
              registered: 100,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 100,
              registered: 112,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 14,
              registered: 12,
            },
          ],
        },
        {
          area: "吴中区",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 20,
              registered: 12,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 256,
              registered: 165,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 1308,
              registered: 986,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 3927,
              registered: 3026,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 6751,
              registered: 5621,
            },
            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 101,
              registered: 86,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 109,
              registered: 98,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 29,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 402,
              registered: 100,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 120,
              registered: 112,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 70,
              registered: 12,
            },
          ],
          total: 300,
        },
        {
          area: "相城区",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 17,
              registered: 9,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 143,
              registered: 86,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 1217,
              registered: 936,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 2204,
              registered: 1862,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 3274,
              registered: 2852,
            },
            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 36,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 85,
              registered: 76,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 26,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 271,
              registered: 100,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 286,
              registered: 112,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 22,
              registered: 12,
            },
          ],
        },
        {
          area: "姑苏区",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 7,
              registered: 3,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 171,
              registered: 103,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 846,
              registered: 689,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 2467,
              registered: 2041,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 5025,
              registered: 4356,
            },
            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 79,
              registered: 45,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 62,
              registered: 58,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 48,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 131,
              registered: 100,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 75,
              registered: 112,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 30,
              registered: 12,
            },
          ],
        },
        {
          area: "工业园区",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 21,
              registered: 0,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 272,
              registered: 159,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 1138,
              registered: 902,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 1536,
              registered: 1251,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 3669,
              registered: 3219,
            },
            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 98,
              registered: 75,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 78,
              registered: 69,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 9,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 327,
              registered: 100,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 218,
              registered: 112,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 12,
              registered: 12,
            },
          ],
        },
        {
          area: "常熟市",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 13,
              registered: 6,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 183,
              registered: 121,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 683,
              registered: 456,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 3856,
              registered: 3421,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 4272,
              registered: 3214,
            },

            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 107,
              registered: 87,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 158,
              registered: 145,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 29,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 412,
              registered: 100,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 922,
              registered: 112,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 170,
              registered: 12,
            },
          ],
        },
        {
          area: "张家港市",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 3,
              registered: 1,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 35,
              registered: 22,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 256,
              registered: 168,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 608,
              registered: 569,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 1235,
              registered: 1021,
            },

            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 21,
              registered: 9,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 49,
              registered: 39,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 33,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 136,
              registered: 100,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 512,
              registered: 112,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 26,
              registered: 12,
            },
          ],
        },
        {
          area: "昆山市",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 25,
              registered: 0,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 386,
              registered: 265,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 2475,
              registered: 2135,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 7594,
              registered: 7321,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 11761,
              registered: 10154,
            },

            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 218,
              registered: 126,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 158,
              registered: 139,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 63,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 477,
              registered: 100,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 1058,
              registered: 112,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 30,
              registered: 12,
            },
          ],
        },
        {
          area: "吴江区",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 33,
              registered: 13,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 235,
              registered: 162,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 1023,
              registered: 952,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 4289,
              registered: 3954,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 11313,
              registered: 9587,
            },
            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 99,
              registered: 69,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 99,
              registered: 85,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 28,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 210,
              registered: 100,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 795,
              registered: 112,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 73,
              registered: 12,
            },
          ],
        },
        {
          area: "太仓市",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 14,
              registered: 4,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 128,
              registered: 81,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 940,
              registered: 679,
            },

            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 2156,
              registered: 1896,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 4194,
              registered: 3856,
            },
            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 70,
              registered: 49,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 159,
              registered: 139,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 9,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 279,
              registered: 100,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 572,
              registered: 112,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 26,
              registered: 12,
            },
          ],
        },
        {
          area: "张家港保税区",
          content: [
            {
              unitCategory: "餐饮服务经营者",
              unitName: "特大型餐饮",
              unRegister: 0,
              registered: 0,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "大型餐饮",
              unRegister: 2,
              registered: 0,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "中型餐饮",
              unRegister: 1,
              registered: 0,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "小型餐饮",
              unRegister: 18,
              registered: 3,
            },
            {
              unitCategory: "餐饮服务经营者",
              unitName: "微型餐饮",
              unRegister: 27,
              registered: 6,
            },
            {
              unitCategory: "单位食堂",
              unitName: "幼托机构食堂",
              unRegister: 0,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "学校食堂",
              unRegister: 0,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "养老机构食堂",
              unRegister: 0,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "工地食堂",
              unRegister: 2,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "机关企事业单位食堂",
              unRegister: 15,
              registered: 0,
            },
            {
              unitCategory: "单位食堂",
              unitName: "其他食堂",
              unRegister: 0,
              registered: 12,
            },
          ],
        },
      ],
     
      list: [],
      query:{
          endDate: "",
          parentCode:  "320500",
          startDate: "",
        }
    };
  },
  created() {
    // this.tableData.map((x, index) => {
    //   let total = this.tableData[index].content
    //     .map((x) => x.unRegister)
    //     .reduce((prev, curr) => prev + curr);
    //   let totalRegister = this.tableData[index].content
    //     .map((x) => x.registered)
    //     .reduce((prev, curr) => prev + curr);
    //   this.$set(x, "total", total);
    //   this.$set(x, "totalRegister", totalRegister);
    // });
    if (this.$route.query.code) {
      this.query.parentCode = this.$route.query.code;
    }
    this.findfindRegister();
  },
  methods: {
    getSummaries(param) {
      //
      // const { columns, data } = param;
      // console.log(columns);
      //    console.log(data);
      // let total=[]
      // columns.forEach((x,index)=>{
      //   if(index==0){
      //   total.push("合计")

      //   }
      //     if(x.index%1==0){

      //       let num = data.map(z=>z.content[Math.floor(x.index)-1].unRegister).reduce((prev, curr) => prev + curr)
      //       total.push(num)
      //     }
      //      if(x.index){
      //       let num = data.map(z=>z.content[Math.floor(x.index)-1].registered).reduce((prev, curr) => prev + curr)
      //       total.push(num)
      //     }
      // })
      //   let data= [
      //     "合计",
      //    this.list[17].shouldRegisterCount,
      //  this.list[17].registeredCount,
      //  (this.list[17].registeredCount/this.list[17].shouldRegisterCount*100).toFixed(0)+'%',
      //       this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',

      //           this.list[7].shouldRegisterCount,
      //  this.list[7].registeredCount,
      //  (this.list[7].registeredCount/this.list[7].shouldRegisterCount*100).toFixed(0)+'%',

      //         this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',
      //        this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',
      //           this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',
      //           this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',
      //         this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',
      //         this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',
      //         this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',
      //         this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',
      //         this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',
      //         this.list[15].shouldRegisterCount,
      //  this.list[15].registeredCount,
      //  (this.list[15].registeredCount/this.list[15].shouldRegisterCount*100).toFixed(0)+'%',
      //   ];
      //
      let shouldRegisterCount = this.list
        .map((x) => x.shouldRegisterCount)
        .reduce((prev, curr) => prev + curr);
      let registeredCount = this.list
        .map((x) => x.registeredCount)
        .reduce((prev, curr) => prev + curr);

      return [
        "合计",
        this.list[11].shouldRegisterCount,
        this.list[11].registeredCount,
        (
          (this.list[11].registeredCount / this.list[11].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",
        this.list[8].shouldRegisterCount,
        this.list[8].registeredCount,
        (
          (this.list[8].registeredCount / this.list[8].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",
        this.list[6].shouldRegisterCount,
        this.list[6].registeredCount,
        (
          (this.list[6].registeredCount / this.list[6].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",

        this.list[9].shouldRegisterCount,
        this.list[9].registeredCount,
        (
          (this.list[9].registeredCount / this.list[9].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",

        this.list[10].shouldRegisterCount,
        this.list[10].registeredCount,
        (
          (this.list[10].registeredCount / this.list[10].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",

        this.list[12].shouldRegisterCount,
        this.list[12].registeredCount,
        (
          (this.list[12].registeredCount / this.list[12].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",

        this.list[7].shouldRegisterCount,
        this.list[7].registeredCount,
        (
          (this.list[7].registeredCount / this.list[7].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",

        this.list[4].shouldRegisterCount,
        this.list[4].registeredCount,
        (
          (this.list[4].registeredCount / this.list[4].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",

        this.list[2].shouldRegisterCount,
        this.list[2].registeredCount,
        (
          (this.list[2].registeredCount / this.list[2].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",

        this.list[1].shouldRegisterCount,
        this.list[1].registeredCount,
        (
          (this.list[1].registeredCount / this.list[1].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",

        this.list[3].shouldRegisterCount,
        this.list[3].registeredCount,
        (
          (this.list[3].registeredCount / this.list[3].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",

        this.list[5].shouldRegisterCount,
        this.list[5].registeredCount,
        (
          (this.list[5].registeredCount / this.list[5].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",
        this.list[0].shouldRegisterCount,
        this.list[0].registeredCount,
        (
          (this.list[0].registeredCount / this.list[0].shouldRegisterCount) *
          100
        ).toFixed(2) + "%",
        shouldRegisterCount,
        registeredCount,
        ((registeredCount / shouldRegisterCount) * 100).toFixed(2) + "%",
      ];
      // const sums = [];
      // columns.forEach((column, index) => {
      //   if (index === 0) {
      //     sums[index] = '总计';
      //     return;
      //   }

      //   const values = data.map(item => Number(item[column.property]));
      //   if (!values.every(value => isNaN(value))) {
      //     sums[index] = values.reduce((prev, curr) => {
      //       const value = Number(curr);
      //       if (!isNaN(value)) {
      //         return prev + curr;
      //       } else {
      //         return prev;
      //       }
      //     }, 0);
      //     sums[index] += '';
      //   } else {
      //     sums[index] = '';
      //   }
      // });
      // return sums;
    },
    onTimeChange(e) {
      if(e){
          this.query.startDate=e[0]
         this.query.endDate=e[1]
      }else{
        this.query.startDate=""
          this.query.endDate="" 
      }
    },
    search() {
        this.findfindRegister()
    },
    getList() {
      this.$http
        .findBodyIndustryRemarksMore(this.query)
        .then((res) => {
          let data = res.data.map((x) => ({
            area: x.districtName,
            list: x.bodyIndustryResponseList,
          }));
          data.forEach((y) => {
            // y.content=y.list.bodyIndustryMoreRemarksResponseList.map(x=>{
            //     return {
            //         unitCategory: y.bodyIndustry,
            //        unitName: x.bodyIndustryRemarks,
            //        unRegister: x.registered,
            //        registered: x.shouldRegister,
            //     }
            // })
            y.content = [];
            y.list.map((z) => {
              let arr = [];
              arr = z.bodyIndustryMoreRemarksResponseList.map((x) => {
                return {
                  unitCategory: z.bodyIndustry,
                  unitName: x.bodyIndustryRemarks,
                  unRegister: x.registerResponseList[0].shouldRegister,
                  registered: x.registerResponseList[0].registered,
                  proportion:
                     x.registerResponseList[0].shouldRegister?(
                      (x.registerResponseList[0].registered /
                        x.registerResponseList[0].shouldRegister) *
                      100
                    ).toFixed(2) + "%":0,
                };
              });
              y.content = [...arr, ...y.content];
            });
          });
          data = data.map((x) => ({ area: x.area, content: x.content }));
          // this.list[11].shouldRegisterCount,
          //     this.list[11].registeredCount,
          //     (
          //       (this.list[11].registeredCount / this.list[11].shouldRegisterCount) *
          //       100
          //     ).toFixed(2) + "%",
          data.push({
            area: "合计",
            content: [
              {
                unitCategory: "餐饮服务经营者",
                unitName: "中型餐饮",
                unRegister: this.list[6].shouldRegisterCount,
                registered: this.list[6].registeredCount,
                proportion:
                 this.list[6].shouldRegisterCount? (
                    (this.list[6].registeredCount /
                      this.list[6].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
              {
                unitCategory: "餐饮服务经营者",
                unitName:  "其他餐饮",
                unRegister: this.list[7].shouldRegisterCount,
                registered: this.list[7].registeredCount,
                proportion:
                   this.list[7].shouldRegisterCount? (
                    (this.list[7].registeredCount /
                      this.list[7].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
              {
                unitCategory: "餐饮服务经营者",
                unitName: "大型餐饮",
                unRegister: this.list[8].shouldRegisterCount,
                registered: this.list[8].registeredCount,
                proportion:
                   this.list[8].shouldRegisterCount? (
                    (this.list[8].registeredCount /
                      this.list[8].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
              {
                unitCategory: "餐饮服务经营者",
                unitName: "小型餐饮",
                unRegister: this.list[9].shouldRegisterCount,
                registered: this.list[9].registeredCount,
                proportion:
                  this.list[9].shouldRegisterCount?  (
                    (this.list[9].registeredCount /
                      this.list[9].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
              {
                unitCategory: "餐饮服务经营者",
                unitName: "微型餐饮",
                unRegister: this.list[10].shouldRegisterCount,
                registered: this.list[10].registeredCount,
                proportion:
                  this.list[10].shouldRegisterCount?  (
                    (this.list[10].registeredCount /
                      this.list[10].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
              {
                unitCategory: "餐饮服务经营者",
                unitName: "特大型餐饮",
                unRegister: this.list[11].shouldRegisterCount,
                registered: this.list[11].registeredCount,
                proportion:
                   this.list[11].shouldRegisterCount? (
                    (this.list[11].registeredCount /
                      this.list[11].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
              {
                unitCategory: "餐饮服务经营者",
                unitName: "集体用餐配送或中央厨房",
                unRegister: this.list[12].shouldRegisterCount,
                registered: this.list[12].registeredCount,
                proportion:
                  this.list[12].shouldRegisterCount?  (
                    (this.list[12].registeredCount /
                      this.list[12].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
              {
                unitCategory: "单位食堂",
                unitName: "其他食堂",
                unRegister: this.list[0].shouldRegisterCount,
                registered: this.list[0].registeredCount,
                proportion:
                   this.list[0].shouldRegisterCount? (
                    (this.list[0].registeredCount /
                      this.list[0].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
              {
                unitCategory: "单位食堂",
                unitName: "养老机构食堂",
                unRegister: this.list[1].shouldRegisterCount,
                registered: this.list[1].registeredCount,
                proportion:
                  this.list[1].shouldRegisterCount?  (
                    (this.list[1].registeredCount /
                      this.list[1].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
              {
                unitCategory: "单位食堂",
                unitName: "学校食堂",
                unRegister: this.list[2].shouldRegisterCount,
                registered: this.list[2].registeredCount,
                proportion:
                  this.list[2].shouldRegisterCount?  (
                    (this.list[2].registeredCount /
                      this.list[2].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
              {
                unitCategory: "单位食堂",
                unitName: "工地食堂",
                unRegister: this.list[3].shouldRegisterCount,
                registered: this.list[3].registeredCount,
                proportion:
                  this.list[6].shouldRegisterCount?  (
                    (this.list[3].registeredCount /
                      this.list[3].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
   {
                unitCategory: "单位食堂",
                unitName: "幼托机构食堂",
                unRegister: this.list[4].shouldRegisterCount,
                registered: this.list[4].registeredCount,
                proportion:
                  this.list[4].shouldRegisterCount?  (
                    (this.list[4].registeredCount /
                      this.list[4].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
  {
                unitCategory: "单位食堂",
                unitName: "机关企事业单位食堂",
                unRegister: this.list[5].shouldRegisterCount,
                registered: this.list[5].registeredCount,
                proportion:
                   this.list[5].shouldRegisterCount? (
                    (this.list[5].registeredCount /
                      this.list[5].shouldRegisterCount) *
                    100
                  ).toFixed(2) + "%":0,
              },
            ],
          });
          this.tableData = data;
          this.tableData.map((x, index) => {
            let total = this.tableData[index].content
              .map((x) => x.unRegister)
              .reduce((prev, curr) => prev + curr);
            let totalRegister = this.tableData[index].content
              .map((x) => x.registered)
              .reduce((prev, curr) => prev + curr);

            let proportion = ((totalRegister / total) * 100).toFixed(2) + "%";
            this.$set(x, "total", total);
            this.$set(x, "totalRegister", totalRegister);
            this.$set(x, "proportion", proportion);
          });
          this.$refs.table.doLayout()
          // this.isTable = true;
          // let list=data.forEach(y=>{
          //    y.content= x.list.map(x=>{
          //       return {
          //           unitCategory:x.bodyIndustry,
          //           unitName:x.bodyIndustryMoreRemarksResponseList,
          //       }
          //   //        {
          //   //   unitCategory: "单位食堂",
          //   //   unitName: "机关企事业单位食堂",
          //   //   unRegister: 15,
          //   //   : 0,
          //   // },
          //     })
          //   })
        });

      //
    },
    findfindRegister() {
      this.$http
        .findfindRegister(this.query)
        .then((res) => {
          this.list = res.data;
          this.getList();
        });
    },
    // 导出
    handleExportMarketingList() {
      // 懒加载，@/common/vendor/Export2Excel 此路径为本地路径
      // 设置当前日期
      //     let time = new Date();
      //     let year = time.getFullYear();
      //     let month = time.getMonth() + 1;
      //     let day = time.getDate();
      //     let name = year + "" + month + "" + day;
      //     // console.log(name)
      //     /* generate workbook object from table */
      //     //  .table要导出的是哪一个表格
      //         let id= ".table"
      //     var wb = XLSX.utils.table_to_book(document.querySelector(".table"));
      //  var fix = document.querySelector('.el-table__fixed');
      // if (fix) {
      //   wb = XLSX.utils.table_to_book(document.querySelector(id).removeChild(fix));
      //   document.querySelector(id).appendChild(fix);
      // } else {
      //   wb = XLSX.utils.table_to_book(document.querySelector(id));
      // }

      //     /* get binary string as output */
      //     var wbout = XLSX.write(wb, {
      //       bookType: "xlsx",
      //       bookSST: true,
      //       type: "array"
      //     });
      //     try {
      //       //  name+'.xlsx'表示导出的excel表格名字
      //       FileSaver.saveAs(
      //         new Blob([wbout], { type: "application/octet-stream" }),
      //         name + ".xlsx"
      //       );
      //     } catch (e) {
      //       if (typeof console !== "undefined") console.log(e, wbout);
      //     }
      //     return wbout;
      //     var fix = document.querySelector('.el-table__fixed');
      //    let id= ".table"
      //    let title="12313"
      // var wb;
      // if (fix) {
      //   wb = XLSX.utils.table_to_book(document.querySelector(id).removeChild(fix));
      //   document.querySelector(id).appendChild(fix);
      // } else {
      //   wb = XLSX.utils.table_to_book(document.querySelector(id));
      // }
      // /* get binary string as output */
      // var wbout = XLSX.write(wb, {
      //   bookType: 'xlsx',
      //   bookSST: true,
      //   type: 'array'
      // });
      // try {
      //   FileSaver.saveAs(
      //     new Blob([wbout], {
      //       type: 'application/octet-stream'
      //     }),
      //     title + ".xlsx"
      //   );
      // } catch (e) {
      //   if (typeof console !== 'undefined') console.log(e, wbout);
      // }
      // return wbout;
      //

      // document.querySelector('.el-table__footer .has-gutter tr td')[0].rowSpan=1
      //

      exportTb(".table", "导出");
    },
    onGoback(){
      this.$router.go(-1)
    }
  },
};
</script>

<style lang="less">
.classroom {
  padding: 20px;

  //   .el-table {
  //     overflow: auto;
  //   }
  //   .el-table--scrollable-x .el-table__body-wrapper {
  //     overflow-x: visible;
  //   }
  //   .el-table__body-wrapper {
  //     overflow: visible;
  //   }
  //   .el-table__header-wrapper {
  //     overflow: visible;
  //   }
  //   .el-table__footer-wrapper {
  //     overflow: visible;
  //   }
  //   .el-table::after {
  //     position: relative !important;
  //   }
}
</style>
